<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">
   msg： {{msg}}
    <div @click="add">获取数据按钮</div>
       {{mydata.ec}}

    <div @click="remove">删除数据按钮</div>
    <div @click="jump">跳转</div>
    <div @click="unbind">取消绑定msg</div>
   
  </div>
</template>

<script lang="ts">
import { useRouter } from "vue-router";
import { useStore } from "vuex";
import request from "@/api/api"
import {reactive,ref,toRaw} from "vue"


export default {
  setup(){

    const store = useStore();
    const router = useRouter();
    const msg = ref("");
    const obj = {em:'默认',ec:18};
     const mydata = reactive(obj);
   
    const jump = ()=>{
     
        router.push("/about")
        
    }
     const add = ()=>{
     
      request.post("/api/buddy/device/equipment/strategyinfo", {}).then((res)=>{
        const {data} = res;
        obj.ec = data.ec
        msg.value = data.em
      });
      
    }
     const remove = ()=>{
      mydata.ec = 0
       msg.value = ''
      
    }
    const unbind = ()=>{
       toRaw(mydata.ec)
      toRaw(msg)
      
    }
    return {jump,mydata,msg,add,remove,unbind}
   


  }
}
</script>
